package com.baifendian.common.task;

import com.baifendian.common.utils.DateUtils;
import com.baifendian.dao.entity.RcApiInterStat;
import com.baifendian.dao.entity.RcApiSysStat;
import com.baifendian.service.RcApiInterStatService;
import com.baifendian.service.RcApiSysStatService;
import java.util.Date;
import java.util.List;
import org.springframework.util.ObjectUtils;

/**
 * @author peng.guo on 2018/3/7.
 */
public class RcApiSysStatTask implements Runnable {

  private String name;

  private RcApiSysStatService rcApiSysStatService;

  public RcApiSysStatTask(RcApiSysStatService rcApiSysStatService,String name) {
    this.rcApiSysStatService = rcApiSysStatService;
    this.name = name;
  }

  @Override
  public void run() {

//    Date date = DateUtils.stringToDate("02/22/2018");
    Date date = DateUtils.localDateTimeToDate(DateUtils.getCurrentTime());
    List<RcApiSysStat> rcApiSysStatList = rcApiSysStatService.getRcApiSysStatList(date);
    if(ObjectUtils.isEmpty(rcApiSysStatList)){
      return;
    }
    rcApiSysStatService.delRcApiSysStat();
    rcApiSysStatService.saveRcApiSysStat(rcApiSysStatList);
    System.out.println("rcApiSysStatList" + rcApiSysStatList);

  }
}
